﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace ProjectDailyReport
{
    public partial class ProjectDailyReportService : ServiceBase
    {
        private ProjectDailyReportServiceImpl CreateNotifierService()
        {
            ReporterSetting ProjectProgressNotifierSetting = new ReporterSetting
            {
                NotifierName = "蘇國棟",
                AccountEmailAddress = "skt90u@gmail.com",
                AccountPassword = "490410056",
                AsyncSend = false,
                MailTo = "skt90u@gmail.com"
            };

            ProjectDailyReportServiceImpl service = new ProjectDailyReportServiceImpl(
                ProjectProgressNotifierSetting,
                5000);

            return service;
        }

        private ProjectDailyReportServiceImpl _service = null;
        private ProjectDailyReportServiceImpl service
        {
            get
            {
                _service = _service ?? CreateNotifierService();

                return _service;
            }
        }

        public ProjectDailyReportService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            service.Start();
        }

        protected override void OnStop()
        {
            service.Stop();
        }

        protected override void OnPause()
        {
            service.Suspend();
        }

        protected override void OnContinue()
        {
            service.Continue();
        }
    }
}
